package com.zzj.controller;

import com.github.pagehelper.PageInfo;
import com.zzj.bean.OrdersBean;
import com.zzj.service.OrdersService;
import com.zzj.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("orders")
@Api
//@CrossOrigin
public class OrdersController {
    @Autowired
    private OrdersService ordersService;

    @PostMapping("add")
    @ApiOperation("添加订单")
    public Result addOrders(@RequestBody Map map){
        return ordersService.addOrders(map);
    }

    @GetMapping("findAll")
    @ApiOperation("查询所有订单")
    public PageInfo<OrdersBean> findAll(
            @RequestParam(defaultValue = "1")int pageNum,
            @RequestParam(defaultValue = "5")int pageSize
    ){
        return ordersService.findAll(pageNum,pageSize);
    }

    @GetMapping("queryCount")
    @ApiOperation("查询订单编号是否重复")
    public Result queryCountvByOoid(int ooid){
        System.out.println("ooid = " + ooid);
        return ordersService.queryCountByOoid(ooid);
    }
}
